package com.xmqsfsky1017.skysrf;

import android.content.Context;

import com.xmqsfsky1017.skysrf.utils.FileHelper;
import com.xmqsfsky1017.skysrf.utils.tree.WeakerTree;
import com.xmqsfsky1017.skysrf.utils.tree.WeakerTree.TreeDieException;
import com.xmqsfsky1017.skysrf.utils.Table;
import com.xmqsfsky1017.skysrf.utils.Table.TableException;

import java.io.IOException;

class Consts{
    private static WeakerTree inputMethodTrieTree;
	private static int initedTime = 0;
    private static Table keyboardSymTable;
		
	public static void init(Context context) throws IOException,TreeDieException{
		if (Consts.initedTime == 0) {
			String treeContent = FileHelper.readFromAssets(context, "SkyTree.xml");
			Consts.inputMethodTrieTree = WeakerTree.load(treeContent);
			Consts.keyboardSymTable=Consts.initKeyboardSymbolsTable(context);
		}
		Consts.initedTime+=1;
	}
	
	private static Table initKeyboardSymbolsTable(Context context) throws IOException {
		String tableString = FileHelper.readFromAssets(context, "keyboard_table.tb");
		return Table.load(tableString);
	}
	
	public static Table getKeyboardSymbolsTable() {return keyboardSymTable;}
	public static WeakerTree getInputMethodTrieTree() {return inputMethodTrieTree;}
	
}